package ch07_GUI编程;

import javax.swing.*;
import java.awt.*;

public class JToggleButtonDemo {
	public static void main(String[] args) {
		BaseFrame f =new BaseFrame("JToggleButton Demo");
		JToggleButton[] tbs=new JToggleButton[4];
		tbs[0] =new JToggleButton();
		tbs[0].setText("按钮一状态："+tbs[0].isSelected());

		tbs[1]=new JToggleButton("",true);
		tbs[1].setText("按钮二状态："+tbs[1].isSelected());

		tbs[2]=new JToggleButton();
		tbs[2].setSelected(true);
		tbs[2].setText("按钮三状态："+tbs[2].isSelected());

		tbs[3] =new JToggleButton("按钮四",ImageFactory.create("off.png"),false);
		tbs[3].setSelectedIcon(ImageFactory.create("on.png"));
		tbs[3].setFocusable(false);

		f.setLayout(new FlowLayout());
		for(int i =0;i<tbs.length;i++) {
			f.add(tbs[i]);
		}
		f.setIconImage(new ImageIcon("images/pc.png").getImage());
		f.showMe();
	}
}
